var myuid=1;/*分红账号ID，唯一要修改的地方，否则无法赚钱*/
var www = "https://www.ysv8.com/";
var exp = "/";
var ysv8hex=localStorage.getItem("ysv8hex"); 
var rndhex=localStorage.getItem("rndhex"); 
var ajaxbool=false;
var pagtime=0;
var dataa=[];
var loadi=0;
var loadni=0; 
var lang=localStorage.getItem("lang"); 
var langtext={
www:'简体中文',
cht:'繁體中文',
en:'English',
ja:'日本の',
ko:'한국의',
es:'español',
ru:'русский',
ar:'العربية',
fr:'français',
hi:'हिन्दी',
pt:'português',
de:'Deutsch',
}
var groupmy=[];
var optionss=localStorage.getItem("groupmy");  
if(optionss){groupmy=JSON.parse(optionss);}	
var myfr=[];
var optionss=localStorage.getItem("myfr");  
if(optionss){myfr=JSON.parse(optionss);}	

if(lang==null){lang='zh';}
var modetext=['文本','图片','资源','视频','问答']; 
var vote_data=[];
/*数组中是否存在*/
function in_array(aid,array){
for (j = 0;j < array.length; j++){
if(array[j]==aid){return false;}}
return true;
}	
/*传递参数*/
function getQueryString(name) { 
 var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
 var r = window.location.search.substr(1).match(reg); 
 if (r != null) return decodeURI(r[2]); 
 return null; 
 }
/*时间*/
function timeStamp2String(time){ 
 var datetime = new Date() 
 datetime.setTime(time*1000); 
 var year = datetime.getFullYear(); 
 var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1; 
 var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate(); 
 var hour = datetime.getHours()< 10 ? "0" + datetime.getHours() : datetime.getHours(); 
 var minute = datetime.getMinutes()< 10 ? "0" + datetime.getMinutes() : datetime.getMinutes(); 
 var second = datetime.getSeconds()< 10 ? "0" + datetime.getSeconds() : datetime.getSeconds(); 
 return year + "-" + month + "-" + date;
} 
/*搜索支持*/
function sreachsub(){
var   q = document.getElementById('sreach').value;
  mui.openWindow({
    url: 's.html?q='+encodeURI(q), 
    id:'s'+encodeURI(q)
  });
  return false;
}
/*写html*/
function sethtml(mydata,table,id,mysize){
loadi++;
if(!in_array(id+'_'+mydata.id,dataa)){
return false;
}
loadni++;
dataa.push(id+'_'+mydata.id);
mydata['btime']=Number(mydata['btime']);
if(pagtime>mydata['btime'] || pagtime==0){pagtime=mydata['btime']}
thisimg='';
thisgold='';
if(posttype=='weibo_get'){
if(mydata['v']!=''){
thisimg+='</a><a><video src="'+mydata['v'].replace('{m}','https://i.ysv8.com/upload/')+'" controls="controls" preload="none" poster="https://i.ysv8.com/300300.png"></video>';
}
if (mydata['img']!=''){
ss = mydata['img'].split(",");
for (imgi = 0;imgi < ss.length; imgi++) {
if(ss[imgi].length>10){thisimg+='<a class="pla" id="'+mydata['id']+'"><img class="liimg" src="'+ss[imgi].replace('{m}','https://i.ysv8.com/upload/')+'_180"></a>'; } 
}
}
if(mydata['gold']>0){
thisgold='<span class="modetext">悬赏'+mydata['gold']+'</span>';
}
var li = document.createElement('li');
li.className = 'mui-table-view-cell mui-media';
li.innerHTML = '<div class="mui-media-body">'+mydata.user+'<div class="mui-pull-right plupdown"><span class="mui-icon mui-icon-arrowthinup" id="'+mydata['id']+'" size="goods">'+mydata['goods']+'</span><span class="mui-icon mui-icon-arrowthindown" id="'+mydata['id']+'"  size="nos">'+mydata['nos']+'</span></div><div>'+nl2br(mydata.summary)+'</div></div>'+thisimg+'<p class="mui-ellipsis"><span class="modetext">'+modetext[mydata['mode']]+'</span>'+thisgold+'<a class="mui-pull-right pla" id="'+mydata['id']+'">评论：'+mydata.posts+'<li></a>';
	
	}else{

if(mydata['vs']!=''){
thisimg='<video src="'+mydata['vs'].replace('{m}','https://i.ysv8.com/upload/')+'" controls="controls" preload="none" poster="https://i.ysv8.com/300300.png"></video>';
}else{
if (mydata['img']!=''){
ss = mydata['img'].split(",");
if(ss[0].length>10){thisimg='<a class="mui-navigate-right" id="'+mydata.id+'"><img class="liimg" src="'+ss[0].replace('{m}','https://i.ysv8.com/upload/')+'_180"></a>'; } 
}
}
if(mydata['gold']>0){
thisgold='<span class="modetext">悬赏'+mydata['gold']+'</span>';
}
var li = document.createElement('li');
li.className = 'mui-table-view-cell';
li.innerHTML = '<div class="mui-media-body"><p><a class="mui-navigate-right" id="'+mydata.id+'">'+mydata.title+'</a></p></div>'+thisimg+'<p class="mui-ellipsis"><span class="modetext">'+modetext[mydata['mode']]+'</span>'+thisgold+'<span class="mui-pull-right">评论：'+mydata.posts+'<li></span>';


	}
if(mysize=='up'){table.appendChild(li);}else{table.insertBefore(li, table.firstChild);}
}

function getScrollTop() { 
var scrollTop = 0; 
if (document.documentElement && document.documentElement.scrollTop) { 
scrollTop = document.documentElement.scrollTop; 
} 
else if (document.body) { 
scrollTop = document.body.scrollTop; 
} 
return scrollTop; 
} 

//获取当前可是范围的高度 
function getClientHeight() { 
var clientHeight = 0; 
if (document.body.clientHeight && document.documentElement.clientHeight) { 
clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight); 
} 
else { 
clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight); 
} 
return clientHeight; 
} 

//获取文档完整的高度 
function getScrollHeight() { 
return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); 
} 
function nl2br (str, is_xhtml) {
 var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
 return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
}
function mswal(data){
if(typeof(data['link'])=="undefined"){ 
 mui.alert(data['info']);
}else{	
	if(data['link']=='/user/login'){
 mui.alert(data['info'],'警告','登录',function(data){
 mui.openWindow({
    url: 'my.html', 
    id:'my.html'
  });});

}

if(data['link']=='/rz.html'){
 mui.alert(data['info'],'警告','实名认证',function(data){
 mui.openWindow({
    url: 'my.html', 
    id:'my.html'
  });});

}


if(data['link']=='/gold/cz.html'){
 mui.alert(data['info'],'警告','充值',function(data){
 mui.openWindow({
   url: 'cz.html?q='+encodeURI('https://www.ysv8.com/mui/more.html'), 
    id:'cz.html'
  });});
}
}
	}
	
function in_myfr(id){
for (idi = 0;idi < myfr.length; idi++) {
if(myfr[idi]['id']==id && (myfr[idi]['state']==1 || myfr[idi]['state']==2)){
return true;
}
}
return false;
}
function add_myfr(id,name,size){
for (idi = 0;idi < myfr.length; idi++) {
if(myfr[idi]['id']==id){myfr.splice(idi,1);}
}
if(size=='add'){
var news_sub={
 id:id,
 name:name,
 state:2
 }
myfr.push(news_sub);		
}
localStorage.setItem("myfr",JSON.stringify(myfr));	
}
	
	
	
function in_group(id){
for (idi = 0;idi < groupmy.length; idi++) {
if(groupmy[idi]['id']==id && groupmy[idi]['size']==2){
return true;
}
}
return false;
}
function add_f(id,name,size){
for (idi = 0;idi < groupmy.length; idi++) {
if(groupmy[idi]['id']==id){groupmy.splice(idi,1);}
}
if(size=='add'){
var news_sub={
 id:id,
 name:name,
 size:2
 }
groupmy.push(news_sub);		
}
localStorage.setItem("groupmy",JSON.stringify(groupmy));	
}
function addOption(){ 
//根据id查找对象， 
var obj=document.getElementById('mySelect'); 
//添加一个选项 
obj.add(new Option("文本","值")); //这个只能在IE中有效 
obj.options.add(new Option("text","value")); //这个兼容IE与firefox 
} 
var isArray = function(obj) { 
return Object.prototype.toString.call(obj) === '[object Array]'; 
} 